<?php
namespace app\php\controller;  // 必须继承于app 第二个是具体的应用名  例 t5/note/tp
use think\Controller;
//use think\Request;


use think\config;


// use think\Db;
class Index2 extends Controller
{

	public $up =array (
		'name'=> '何发给',
		  'age'=>'100'
	);
    public $up2 = [
		'name'=> '何发给2',
		  'age'=>'100'
		];
	public $up3 =array('点击','51');	
	public $up4 = ['菠萝','苹果'];

/**
 * 二维数组
 */

public $cyy = array(
	'0'=>array(
		'name'=>"仿京东登陆",
		'address'=>"家地址  ",
		'link'=>"note.php/boot/Login/index",
	),
	'1'=>array(
		'name'=>"仿京东注册",
		'address'=>"地址3",
		'link'=>"link8",

	),
	'2'=>array(
		'name'=>"横向二级菜单 ",
		'address'=>"家地址 ",
		'link'=>"note.php/boot/Caidan/index",

	),
);

public $cyy2 = array(
	'名称1'=>array(
		'name'=>"仿京东登陆",
		'address'=>"家地址  ",
		'link'=>"note.php/boot/Login/index",
	),
	'名称k'=>array(
		'name'=>"仿京东注册",
		'address'=>"地址3",
		'link'=>"link8",

	),
	'名称新'=>array(
		'name'=>"横向二级菜单 ",
		'address'=>"家地址 ",
		'link'=>"note.php/boot/Caidan/index",

	),
);

/**
 * 向二维数组添加一个元素
 */
public function index(){
	//dump($this->cyy);
     $this->cyy[] = [
		'name' => '5451351',
		'address' => 'fdfk',
		'link' => 'note.php/boot/Cai/index',
	];
	$this->index2();
	dump($this->cyy);
}
public function index2(){
	echo'
	<pre>
     $this->cyy[] = [
		\'name\' => \'5451351\',
		\'address\' => \'fdfk\',
		\'link\' => \'note.php/boot/Cai/index\',
	];
	<hr/>
	</pre>
	';
}

/**
 * 删除二维数组中 某一个元素
 */
public function index3(){
	$arr = $this->cyy;
	foreach ($arr as $key => $value) { 
		if ($value['name'] == "仿京东注册") { 
			unset($arr[$key]); 
		} 
	}
	$this->index4();
	dump($arr);
}
public function index4(){
	echo'
	<pre>
	原来有三个值，删除一个 还剩两个值
	$arr = $this->cyy;
	foreach ($arr as $key => $value) { 
		if ($value[\'name\'] == "仿京东注册") { 
			unset($arr[$key]);   //删除
		} 
	}
	<hr/>
	</pre>
	';

}

/**
 * 无键值对 向二维数组添加元素
 */
public function index5(){
	$id = '51351';
	$name = '小杨';
	$arr[] = array($id,$name);
	$id2 = '4513';
	$name2 = '小李';
	$arr[] = array($id2,$name2);
	$id3 = '451355';
	$name3 = '小褚';
	$arr[] = array($id3,$name3);
	$this->arr = $arr;
	$this->index6();
	dump($arr);

}
public function index6(){
   echo'
   <pre>
	$id3 = \'451355\';
	$name3 = \'小褚\';
	$arr[] = array($id3,$name3);
	<hr/>
	</pre>
	';
}

/**
 * 无键值对 从二维数组中删除一个元素
 */
public function index7(){
	$id = '51351';
	$name = '小杨';
	$arr[] = array($id,$name);
	$id2 = '4513';
	$name2 = '小李';
	$arr[] = array($id2,$name2);
	$id3 = '451355';
	$name3 = '小褚';
	$arr[] = array($id3,$name3);
	echo(count($arr));
	for($x=0; $x<count($arr); $x++){
     if($arr[$x]['1'] == '小李'){
		unset($arr[$x]);   //删除
	 }
	 }
	 $this->index8();
	 dump($arr);

}

public function index8(){
	echo'
	<pre>
	<hr/>

	for($x=0; $x&lt;count($arr); $x++){
     if($arr[$x][\'1\'] == \'小李\'){
		unset($arr[$x]);   //删除
	 }
	 }
     <hr/>
	 </pre>
	 ';
	 

}





/**
 * 二维数组 排序
 */
public function index9(){
	$data = array();
    $data[] = array('volume' => 67, 'edition' => 2);
    $data[] = array('volume' => 86, 'edition' => 1);
    $data[] = array('volume' => 85, 'edition' => 6);
    $data[] = array('volume' => 98, 'edition' => 2);
    $data[] = array('volume' => 86, 'edition' => 6);
    $data[] = array('volume' => 67, 'edition' => 7);

    // 取得列的列表  desc 降序
    foreach ($data as $key => $row)
    {
        $volume[$key]  = $row['volume'];
        $edition[$key] = $row['edition'];
    }

	array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);
	$this->index10();
dump($data);
}

public function index10(){
	echo'
	<pre>
	<hr/>
	$data = array();
    $data[] = array(\'volume\' => 67, \'edition\' => 2);
    $data[] = array(\'volume\' => 86, \'edition\' => 1);
    $data[] = array(\'volume\' => 85, \'edition\' => 6);
    $data[] = array(\'volume\' => 98, \'edition\' => 2);
    $data[] = array(\'volume\' => 86, \'edition\' => 6);
    $data[] = array(\'volume\' => 67, \'edition\' => 7);

    // 取得列的列表  desc 降序
    foreach ($data as $key => $row)
    {
        $volume[$key]  = $row[\'volume\'];
        $edition[$key] = $row[\'edition\'];
    }

    array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);
<hr/>
</pre>
';
}

public function index11(){
    dump($this->cyy);
    $all_address = array_column($this->cyy,'address'); 
	dump($all_address);
	echo'
	<hr/>
	<h4>核心代码</h4>
	$all_address = array_column($this->cyy,\'address\'); 
	';
}





}